using MediatR;

namespace TerritoryGame.Application.Queries;

public record GetGameStateQuery : IRequest<GetGameStateResult>
{
    public Guid GameId { get; init; }
}

public record GetGameStateResult
{
    public bool Success { get; init; }
    public string? ErrorMessage { get; init; }
    public GameStateInfo? GameState { get; init; }
}

public record GameStateInfo
{
    public Guid GameId { get; init; }
    public Guid RoomId { get; init; }
    public string RoomName { get; init; } = string.Empty;
    public string Status { get; init; } = string.Empty;
    public DateTime? StartTime { get; init; }
    public int GameDuration { get; init; }
    public int RemainingTime { get; init; }
    public List<PlayerStateInfo> Players { get; init; } = new();
    public CanvasInfo Canvas { get; init; } = new();
}

public record PlayerStateInfo
{
    public Guid Id { get; init; }
    public string NickName { get; init; } = string.Empty;
    public string Color { get; init; } = string.Empty;
    public int Score { get; init; }
    public int Area { get; init; } // 玩家占领的面积
    public bool IsOnline { get; init; }
}

public record CanvasInfo
{
    public int Width { get; init; }
    public int Height { get; init; }
    public Dictionary<string, string> Pixels { get; init; } = new(); // Position -> Color
}
